$(function() {

	$("#submit").on("click", function() {
		submit();
	});
});
function submit() {
	var x = $("#form").serializeArray();
	$.post("/groupRelationship/dealSave", x, function(data, status) {
		if (data == "ok") {
			var dialog = BootstrapDialog.show({
				title : '提示',
				message : "提交成功",
				buttons : [ {
					label : "确定",
					cssClass : "btn-primary", // 给按钮添加类名
					action : function(dialog) { // 给当前按钮添加点击事件
						try {
							parent.$("#table").bootstrapTable('refresh');
						} catch (e) {
							var gri = "groupRelationships_" + $("#id").val();
							parent.$("#" + gri).closest("li").remove();
						}
						dialog.close();
						var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
						parent.layer.close(index);// 关闭弹出的子页面窗口
					}
				} ]
			});
		} else {
			var dialog = BootstrapDialog.show({
				title : '提示',
				message : data,
				buttons : [ {
					label : "确定",
					cssClass : "btn-primary", // 给按钮添加类名
					action : function(dialog) { // 给当前按钮添加点击事件
						dialog.close();
					}
				} ]
			});
		}
	});
};
function download() {

	var url = "/groupRelationship/download";

	var tempForm = document.createElement("form");
	tempForm.id = "tempForm";
	tempForm.method = "post";
	tempForm.action = url;
	tempForm.target = "blank";

	var hideInput = document.createElement("input");
	hideInput.type = "hidden";
	hideInput.name = "file";
	hideInput.value = $("#fileStr").val();
	tempForm.appendChild(hideInput);

	hideInput = document.createElement("input");
	hideInput.type = "hidden";
	hideInput.name = "fileName";
	hideInput.value = $("#fileName").val();
	tempForm.appendChild(hideInput);

	if (tempForm.attachEvent) { // IE
		tempForm.attachEvent("onsubmit", function() {
			window.open('about:blank', 'blank');
		});
	} else if (tempForm.addEventListener) { // DOM Level 2 standard
		tempForm.addEventListener("onsubmit", function() {
			window.open('about:blank', 'blank');
		});
	}
	document.body.appendChild(tempForm);
	if (document.createEvent) { // DOM Level 2 standard
		evt = document.createEvent("MouseEvents");
		evt.initMouseEvent("submit", true, true, window, 0, 0, 0, 0, 0, false,
				false, false, false, 0, null);
		tempForm.dispatchEvent(evt);
	} else if (tempForm.fireEvent) { // IE
		tempForm.fireEvent('onsubmit');
	}
	// 必须手动的触发
	tempForm.submit();
	document.body.removeChild(tempForm);

}
